CentOS 6
Sponsored Link

HAProxy : Refer to the Statistics#2
2015/01/22
 
Configure HAProxy to see HAProxy's Statistics with commands.
[1] Install some packages.
# install from EPEL

[root@dlp ~]#
yum --enablerepo=epel -y install socat
[2] Configure HAProxy.
[root@dlp ~]#
vi /etc/haproxy/haproxy.cfg
# add follows in the "global" section

global
      # binds UNIX sockets

    stats socket /var/lib/haproxy/stats

[root@dlp ~]#
/etc/rc.d/init.d/haproxy restart

Stopping haproxy: [ OK ]
Starting haproxy: [ OK ]
[3] Refer to the Statistics like follows.
# display current stats

[root@dlp ~]#
echo "show info" | socat /var/lib/haproxy/stats stdio
Name: HAProxy
Version: 1.5.2
Release_date: 2014/07/12
Nbproc: 1
Process_num: 1
Pid: 1297
...
...
Idle_pct: 100
node: dlp.srv.world
description:
# display stas with CSV

[root@dlp ~]#
echo "show stat" | socat /var/lib/haproxy/stats stdio
# pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp.....
http-in,FRONTEND,,,0,1,2000,2,0,374,0,0,2,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,1,,,,0,0,0,2,0.....
backend_servers,www01,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,574,0,,1,3,1,,0,,2,0,,0,L4O.....
backend_servers,www02,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,574,0,,1,3,2,,0,,2,0,,0,L4O.....
backend_servers,BACKEND,0,0,0,0,200,0,0,0,0,0,,0,0,0,0,UP,2,2,0,,0,574,0,,1,3,0,,0,,1,0.....
# display current session

[root@dlp ~]#
echo "show sess" | socat /var/lib/haproxy/stats stdio
0x1759ff0: proto=unix_stream src=unix:1 fe=GLOBAL be=<NONE> srv=<none> ts=0b age=0s calls=1 
rq[f=c08200h,i=0,an=00h,rx=10s,wx=,ax=] rp[f=008000h,i=0,an=00h,rx=,wx=,ax=] s0=[7,8h,fd=1,ex=] s1=[7,8h,fd=-1,ex=] exp=
# foe other operations

# enter the interactive mode

[root@dlp ~]#
socat readline /var/lib/haproxy/stats
prompt
# show help

>
help

Unknown command. Please enter one of the following commands only :
  clear counters : clear max statistics counters (add 'all' for all counters)
  clear table    : remove an entry from a table
  help           : this message
  prompt         : toggle interactive mode with prompt
  quit           : disconnect
  show info      : report information about the running process
  show pools     : report information about the memory pools usage
  show stat      : report counters for each proxy and server
  show errors    : report last request and response errors for each proxy
  show sess [id] : report the list of current sessions or dump this session
  show table [id]: report table usage stats or dump this table's contents
  get weight     : report a server's current weight
  set weight     : change a server's weight
  set server     : change a server's state or weight
  set table [id] : update or create a table entry's data
  set timeout    : change a timeout setting
  set maxconn    : change a maxconn setting
  set rate-limit : change a rate limiting value
  disable        : put a server or frontend in maintenance mode
  enable         : re-enable a server or frontend which is in maintenance mode
  shutdown       : kill a session or a frontend (eg:to release listening ports)
  show acl [id]  : report avalaible acls or dump an acl's contents
  get acl        : reports the patterns matching a sample for an ACL
  add acl        : add acl entry
  del acl        : delete acl entry
  clear acl <id> : clear the content of this acl
  show map [id]  : report avalaible maps or dump a map's contents
  get map        : reports the keys and values matching a sample for a map
  set map        : modify map entry
  add map        : add map entry
  del map        : delete map entry
  clear map <id> : clear the content of this map
  set ssl <stmt> : set statement for ssl

# exit from interactive mode

>
quit

 
Tweet